package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.EsMangerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: 大佬味的小男孩
 * @date: 2020-07-22 22:33
 **/
@RequestMapping("manger")
@RestController
public class ESMangerController {
    @Autowired
    private EsMangerService esMangerService;

    //创建索引库结构
    @GetMapping("create")
    public Result create() {
        esMangerService.createMappingAndIndex();
        return new Result(true, StatusCode.OK, "创建索引库成功");
    }

    //导入全部数据进入es
    @GetMapping("importAll")
    public Result importAll() {
        esMangerService.importAll();
        return new Result(true, StatusCode.OK, "全部数据导入es索引库成功");
    }

    //根据spuid查询skuList,再导入索引库
   /* public Result importDataBySpuId( String spuId) {
        esMangerService.importDataBySpuId(spuId);
        return new Result(true, StatusCode.OK, "选中数据导入es索引库成功");
    }*/

}
